﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using ZoneFiveSoftware.Common.Data;
using ZoneFiveSoftware.Common.Data.Fitness;
using ZoneFiveSoftware.Common.Data.GPS;
using ZoneFiveSoftware.Common.Visuals;

namespace BENBUN.UI.Confirmations
{
    public partial class ExportConfirm : Form
    {
        public IActivity activity;
        public Boolean exportConfirmed;
        public ExportConfirm()
        {
            InitializeComponent();
        }

        private void ExportConfirm_Activated(object sender, EventArgs e)
        {
            this.exportConfirmed = false;

            if ((activity.Name != null) && (activity.Name != ""))
            {
                this.labelName.Text = activity.Name;
            }
            else
            {
                this.labelName.Text = "{none}";
            }

            if ((activity.Location != null) && (activity.Location != ""))
            {
                this.labelLocation.Text = activity.Location;
            }
            else
            {
                this.labelLocation.Text = "{none}";
            }
            
            //
            // Format the date/time in local time
            //
            this.labelStartTime.Text = activity.StartTime.ToLocalTime().ToString("ddd") + " " + activity.StartTime.ToLocalTime().ToShortDateString();
            if (activity.HasStartTime)
            {
                this.labelStartTime.Text += " - " + activity.StartTime.ToLocalTime().ToShortTimeString();
            }

            //
            // Format the category into a compounded string so it displays nicely.
            //
            string tempCategory;
            IActivityCategory parentCategory;

            tempCategory = activity.Category.Name;
            if (activity.Category.Parent != null)
            {
                parentCategory = activity.Category.Parent;
                tempCategory = parentCategory.Name + " > " + activity.Category.Name;
                while (parentCategory.Parent != null)
                {
                    parentCategory = parentCategory.Parent;
                    tempCategory = parentCategory.Name + " > " + tempCategory;
                }
            }

            this.labelCategory.Text = tempCategory;
        }

        private void buttonNo_Click(object sender, EventArgs e)
        {
            exportConfirmed = false;
            this.Close();
        }

        private void buttonYes_Click(object sender, EventArgs e)
        {
            exportConfirmed = true;
            this.Close();
        }
    }
}
